package com.tyut.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tyut.common.annotation.Log;
import com.tyut.common.core.controller.BaseController;
import com.tyut.common.core.domain.AjaxResult;
import com.tyut.common.enums.BusinessType;
import com.tyut.system.domain.TyutLaboPatent;
import com.tyut.system.service.ITyutLaboPatentService;
import com.tyut.common.utils.poi.ExcelUtil;
import com.tyut.common.core.page.TableDataInfo;

/**
 * 专利管理Controller
 * 
 * @author tyut
 * @date 2023-11-21
 */
@RestController
@RequestMapping("/patent/stuPatent")
public class TyutLaboPatentController extends BaseController
{
    @Autowired
    private ITyutLaboPatentService tyutLaboPatentService;

    /**
     * 查询专利管理列表
     */
    @PreAuthorize("@ss.hasPermi('patent:stuPatent:list')")
    @GetMapping("/list")
    public TableDataInfo list(TyutLaboPatent tyutLaboPatent)
    {
        startPage();
        List<TyutLaboPatent> list = tyutLaboPatentService.selectTyutLaboPatentList(tyutLaboPatent);
        return getDataTable(list);
    }

    /**
     * 导出专利管理列表
     */
    @PreAuthorize("@ss.hasPermi('patent:stuPatent:export')")
    @Log(title = "专利管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TyutLaboPatent tyutLaboPatent)
    {
        List<TyutLaboPatent> list = tyutLaboPatentService.selectTyutLaboPatentList(tyutLaboPatent);
        ExcelUtil<TyutLaboPatent> util = new ExcelUtil<TyutLaboPatent>(TyutLaboPatent.class);
        util.exportExcel(response, list, "专利管理数据");
    }

    /**
     * 获取专利管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('patent:stuPatent:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tyutLaboPatentService.selectTyutLaboPatentById(id));
    }

    /**
     * 新增专利管理
     */
    @PreAuthorize("@ss.hasPermi('patent:stuPatent:add')")
    @Log(title = "专利管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TyutLaboPatent tyutLaboPatent)
    {
        return toAjax(tyutLaboPatentService.insertTyutLaboPatent(tyutLaboPatent));
    }

    /**
     * 修改专利管理
     */
    @PreAuthorize("@ss.hasPermi('patent:stuPatent:edit')")
    @Log(title = "专利管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TyutLaboPatent tyutLaboPatent)
    {
        return toAjax(tyutLaboPatentService.updateTyutLaboPatent(tyutLaboPatent));
    }

    /**
     * 删除专利管理
     */
    @PreAuthorize("@ss.hasPermi('patent:stuPatent:remove')")
    @Log(title = "专利管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tyutLaboPatentService.deleteTyutLaboPatentByIds(ids));
    }
}
